﻿@{
    ViewBag.Title = "Журнал событий";
    var filePath = Server.MapPath("~/weblog.txt");
    string logData = "Нет записей!";
}

<h2>@ViewBag.Title</h2>

@{
    if (File.Exists(filePath))
    {
        Stream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        var streamReader = new StreamReader(stream);
        logData = streamReader.ReadToEnd();    
    }
}

<div>
    @foreach (var logEntry in logData.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
    {
        @Html.Raw(logEntry)
    }
    
</div>